package xyz.xmh.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 2021/10/20 4:22 星期三<br/>
 * 简化调用，api程序员
 *
 * @author xuMingHai
 */
public final class Md5Utils {

    private Md5Utils() {
    }


    /**
     * 进行md5摘要
     *
     * @param bytes 要进行摘要的消息
     * @return md5值
     */
    public static String digest(byte[] bytes) {
        try {
            final MessageDigest md5 = MessageDigest.getInstance("MD5");
            return new BigInteger(1, md5.digest(bytes)).toString(16);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return "";
    }


}
